<?
include ('../sessions.php');
include ('../variables.php');
include('functions.php');
//include('functions.php');
$webDIR="admin";
include("session_check.php");
if (getenv(REQUEST_METHOD) == "GET") {
	switch($action) {
		case "mainPanel":
			$fileTemplate="mainPanel.html";
			include("main.html");
		break;
		case "changeDetails":
			$fileTemplate="changeDetails.html";
			include("main.html");
		break;
                case "editPlans":
                        $fileTemplate="editPlans.html";
                        include("main.html");
                break;
                case "sales":
                        $fileTemplate="sales.html";
                        include("main.html");
                break;
                case "payments":
                        $fileTemplate="payments.html";
                        include("main.html");
                break;
		case "logout":
                        kill_session($sid);
                        header("Location: $baseURL/members/");		
		break;
		default:
                        $fileTemplate="adminPanel.html";
                        include("main.html");
		break;
		//-----admin---------------------
		case "clear_id":
                       $id = '';		
                       session_unregister_(id,sid);
		       session_save(sid);
		       $fileTemplate = $ft;
		       include("main.html");		
		       exit();
		break;
	        case "create_packet":
                        $fileTemplate="createPacket.html";
			include("main.html");
                break;
                case "edit_packet":
                        $fileTemplate="editPackets.html";
			include("main.html");
                break;
                case "set_reseller":
                        if($resellername){
                                $userName = $resellername;
				$id = get_reseller_id($userName);				
				session_register_(id,userName);
                                session_save(sid);
                                $fileTemplate="mainPanel.html";
				include("main.html");
                        }
                        else{
                                exit("ERROR WHILE SET NEW RESELLER. Please contact CBFL !");
                        }
                break;
		case "list_resellers":
			$fileTemplate="resellersList.html";
			include("main.html");
		break;
		case "list_resellers_domains":
			$fileTemplate="listDomains.html";
			include("main.html");
		break;

		case "search_reseller":
			$fileTemplate="search.html";
			include("main.html");
			exit_now();
		break;
		case "users":
			$fileTemplate="users.html";
			include("main.html");
			exit_now();
		break;
		case "get_mail":
			$fileTemplate="mail.html";
			include("main.html");
			exit_now();
		break;
		case "stats":
			$params[sid]=$sid;
			$params[action]=$action;
			header("Location: $baseURL/$webDIR/stats/?".encode_params($params));
			exit_now();
		break;
		case "client_search":
			$fileTemplate="client_search.html";
			include("main.html");
		break;

                case "client_refund":
                        $fileTemplate="client_refund.html";
                        include("main.html");
                break;
		case "last_sales":
			$fileTemplate="last_sales.html";
			include("main.html");
		break;
		case "last_reseller_sales":
			$fileTemplate="last_reseller_sales.html";
			include("main.html");
		break;
		case "last_payments":
			$fileTemplate="last_payments.html";
			include("main.html");
		break;
		case "services":
                       $fileTemplate="services.html";
                       include("main.html");
		break;
                case "stats_cbfl":
                       $fileTemplate="stats.php";
                       include("main.html");
                break;
                case "graphics":
                       $fileTemplate="graphics/index.php";
                       include("main.html");
                break;
		case "block_reseller":
			$fileTemplate="block_reseller.html";
			include("block_reseller.html");
		break;
		case "w9_submit":
			include("submit_w9_form.html");
		break;
		case "view_affiliates":
			include("view_affiliates.html");
		break;
		case "broken_billing":
			$fileTemplate="broken_billing.html";
			include("main.html");
		break;
                case "referer_details":
                        $fileTemplate="referer_details.html";
                        include("main.html");
                break;
                case "repair":			
			//set_default_settings($res_id);
			$SQL[] = "INSERT INTO interface values('$res_id','0','styles.css','','','','','','','','','','','');";
			transaction($SQL);
			header("Location: http://www.duoservers.com/?id=$res_id");
                break;
		case "get_cclog_info":
			include("get_cclog_info.html");			
		break;
		//-----admin---------------------
	}
}else if(getenv(REQUEST_METHOD) == "POST"){
	switch($action){
		case "create_packet":
			$plan=$HTTP_POST_VARS[plan];
                        $description=$HTTP_POST_VARS[description];
                        $alias=$HTTP_POST_VARS[alias];
                        $setup_fee_max=$HTTP_POST_VARS[setup_fee_max];
                        $plan_min_price=$HTTP_POST_VARS[plan_min_price];
                        $plan_real_price=$HTTP_POST_VARS[plan_real_price];
                        $plan_max_price=$HTTP_POST_VARS[plan_max_price];
                        $domain_min_price=$HTTP_POST_VARS[domain_min_price];
                        $domain_real_price=$HTTP_POST_VARS[domain_real_price];
                        $domain_max_price=$HTTP_POST_VARS[domain_max_price];


                        if(!validate(description)){ $errorCode=1; $errorMsg=" invalid description "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(alias)){ $errorCode=1; $errorMsg=" invalid alias "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(setup_fee_max)){ $errorCode=1; $errorMsg=" invalid setup_fee_max "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(plan_min_price)){ $errorCode=1; $errorMsg=" invalid plan_min_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(plan_real_price)){ $errorCode=1; $errorMsg=" invalid plan_real_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(plan_max_price)){ $errorCode=1; $errorMsg=" invalid plan_max_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(domain_min_price)){ $errorCode=1; $errorMsg=" invalid domain_min_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(domain_real_price)){ $errorCode=1; $errorMsg=" invalid domain_real_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!validate(domain_max_price)){ $errorCode=1; $errorMsg=" invalid domain_max_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
                        if(!add_packet($plan, $description, $alias, $setup_fee_max, $plan_min_price, $plan_real_price, $plan_max_price, $domain_min_price, $domain_real_price, $domain_max_price)) { $errorCode=1; $errorMsg="error updating  "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }

                                $statusMsg="Packet added successfully";
                                session_save(sid);
                                $params[sid]=$sid;
                                $params[action]='edit_packet';
                                $url="$baseURL/$webDIR/?".encode_params($params);
                                header("Location: $url");
                                exit_now();

		break;
		case "edit_packet";
			
			$description=$HTTP_POST_VARS[description]; 
			$alias=$HTTP_POST_VARS[alias]; 
			$setup_fee_max=$HTTP_POST_VARS[setup_fee_max]; 
			$plan_min_price=$HTTP_POST_VARS[plan_min_price]; 
			$plan_real_price=$HTTP_POST_VARS[plan_real_price]; 
			$plan_max_price=$HTTP_POST_VARS[plan_max_price]; 
			$domain_min_price=$HTTP_POST_VARS[domain_min_price]; 
			$domain_real_price=$HTTP_POST_VARS[domain_real_price]; 
			$domain_max_price=$HTTP_POST_VARS[domain_max_price]; 


			if(!validate(description)){ $errorCode=1; $errorMsg=" invalid description "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(alias)){ $errorCode=1; $errorMsg=" invalid alias "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(setup_fee_max)){ $errorCode=1; $errorMsg=" invalid setup_fee_max "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(plan_min_price)){ $errorCode=1; $errorMsg=" invalid plan_min_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(plan_real_price)){ $errorCode=1; $errorMsg=" invalid plan_real_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(plan_max_price)){ $errorCode=1; $errorMsg=" invalid plan_max_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(domain_min_price)){ $errorCode=1; $errorMsg=" invalid domain_min_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(domain_real_price)){ $errorCode=1; $errorMsg=" invalid domain_real_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); } 
			if(!validate(domain_max_price)){ $errorCode=1; $errorMsg=" invalid domain_max_price "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
			if(!change_packet($plan, $description, $alias, $setup_fee_max, $plan_min_price, $plan_real_price, $plan_max_price, $domain_min_price, $domain_real_price, $domain_max_price)) { $errorCode=1; $errorMsg="error updating  "; $fileTemplate="editPackets.html"; include("main.html"); exit(); }
			
                                $statusMsg="Packet detils successfully chenged";
                                session_save(sid);
                                $params[sid]=$sid;
                                $params[action]='edit_packet';
                                $url="$baseURL/$webDIR/?".encode_params($params);
                                header("Location: $url");
                                exit_now();

		break;
		case "changeDetails":
                                $info[reseller]=$HTTP_POST_VARS[reseller];
                                $info[password]=$HTTP_POST_VARS[password];
                                $info[repassword]=$HTTP_POST_VARS[repassword];
                                $info[firstname]=$HTTP_POST_VARS[firstname];
                                $info[lastname]=$HTTP_POST_VARS[lastname];
                                $info[email]=$HTTP_POST_VARS[email];
                                $info[phone]=$HTTP_POST_VARS[phone];
                                $info[address1]=$HTTP_POST_VARS[address1];
                                $info[address2]=$HTTP_POST_VARS[address2];
                                $info[city]=$HTTP_POST_VARS[city];
                                $info[state]=$HTTP_POST_VARS[state];
                                $info[zip]=$HTTP_POST_VARS[zip];
                                $info[country]=$HTTP_POST_VARS[country];


                                if($info[password]){
                                	if(!validate($info[password])){ $errorCode=2; $errorMsg=" invalid password "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                	if(!validate($info[repassword])){ $errorCode=2; $errorMsg=" invalid repassword "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }                              
                                	if($info[password]!=$info[repassword])  { $errorCode=2; $errorMsg="passwords do not match "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                }
                                if(!validate($info[firstname])){ $errorCode=3; $errorMsg=" invalid firstname "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[lastname])){ $errorCode=4; $errorMsg=" invalid lastname "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[email])){ $errorCode=5; $errorMsg=" invalid email "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[phone])){ $errorCode=6; $errorMsg=" invalid phone "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[address1])){ $errorCode=7; $errorMsg=" invalid address1 "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                //if(!validate($info[address2])){ $errorCode=7; $errorMsg=" invalid address2 "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[city])){ $errorCode=8; $errorMsg=" invalid city "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[state])){ $errorCode=9; $errorMsg=" invalid state "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[zip])){ $errorCode=10; $errorMsg=" invalid zip "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
                                if(!validate($info[country])){ $errorCode=11; $errorMsg=" invalid country "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
				if(!change_details($id,$info)){ $errorCode=0; $errorMsg=" Error #1. Please contact the support "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
          
				$info = "";          
				$info[current_release_level]=$HTTP_POST_VARS[current_release_level]; 
				$info[payment_method]=$HTTP_POST_VARS[payment_method]; 
				$info[swift_code]=$HTTP_POST_VARS[swift_code]; 
				$info[bank_name]=$HTTP_POST_VARS[bank_name]; 
				$info[bank_address]=$HTTP_POST_VARS[bank_address]; 
				$info[account_number]=$HTTP_POST_VARS[account_number]; 
				$info[routing_number]=$HTTP_POST_VARS[routing_number]; 
				$info[account_holder]=$HTTP_POST_VARS[account_holder];           			

				if($info[payment_method] == 'wire'){
					if(!validate($info[current_release_level])){ $errorCode=19; $errorMsg=" invalid current_release_level "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[payment_method])){ $errorCode=18; $errorMsg=" invalid payment_method "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[swift_code])){ $errorCode=12; $errorMsg=" invalid swift_code "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[bank_name])){ $errorCode=13; $errorMsg=" invalid bank_name "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[bank_address])){ $errorCode=14; $errorMsg=" invalid bank_address "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[account_number])){ $errorCode=15; $errorMsg=" invalid account_number "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[routing_number])){ $errorCode=16; $errorMsg=" invalid routing_number "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
					if(!validate($info[account_holder])){ $errorCode=17; $errorMsg=" invalid account_holder "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }
				}
				if(!change_bank_details($id,$info)){ $errorCode=0; $errorMsg=" Error #2. Please contact the support "; $fileTemplate= 'changeDetails.html'; include('main.html');  exit(); }						
                                $statusMsg="Your detils successfully chenged";
                                session_save(sid);				
                                $params[sid]=$sid;
                                $params[action]='mainPanel';
                                $url="$baseURL/$webDIR/?".encode_params($params);
                                header("Location: $url");
                                exit_now();
		break;
		case "editPlans":
			$settings =$HTTP_POST_VARS[settings]; 
			$interface =$HTTP_POST_VARS[interface]; 
			
                        if(is_array($interface)){
                                if(!is_array($interface[plans])){$errorMsg="You must select 1 or more plans to be displayed.";$fileTemplate="editPlans.html";include('main.html');exit();}
                        }
			if(is_array($settings)){
				while(list($k,$v) = each($settings)){
					$v[plan] = $k;
					$sys = list_plan_details($k,'array');
					$sys = $sys[0];
					if($v[setup_fee] > $sys[setup_fee_max]){ $errorMsg="The setup fee can't be more than \$ $sys[setup_fee_max]  for '$k'."; $fileTemplate="editPlans.html";include('main.html');exit();}
					if($v[domain_yn] && ($v[domain_price] > $sys[domain_max_price])){ $errorMsg="The domain price can't be more than \$ $sys[domain_max_price]  for '$k'."; $fileTemplate="editPlans.html";include('main.html');exit();}
					if($v[domain_yn] && ($v[domain_price] < $sys[domain_min_price])){ $errorMsg="The domain price can't be less than \$ $sys[domain_min_price]  for '$k'."; $fileTemplate="editPlans.html";include('main.html');exit();}
                                        if($v[plan_yn] && ($v[plan_price] > $sys[plan_max_price])){ $errorMsg="The plan price can't be more than \$ $sys[plan_max_price] for '$k'."; $fileTemplate="editPlans.html";include('main.html');exit();}
                                        if($v[plan_yn] && ($v[plan_price] < $sys[plan_min_price])){ $errorMsg="The plan price can't be less than \$ $sys[plan_min_price] for '$k'."; $fileTemplate="editPlans.html";include('main.html');exit();}

					if(!$v[domain_yn]) $v[domain_price]='NULL';
					if(!$v[plan_yn]) $v[plan_price]='NULL';
					if(!change_plan_settings($id,$v)) exit("ERROR #1.Please contact the support.($k)");
					
					if($interface[plans][$k]=='true'){
                                                $set[plan]=$k;
                                                $set[display]='true';
                                                $set[domain]=$interface[domains][$k];
					}
					else{
                                                $set[plan]=$k;
                                                $set[display]='false';
                                                $set[domain]=$interface[domains][$k];
					}
					if(!change_interface_settings($id,$set)) exit("ERROR #2.Please contact the support.($k)");
				}
			}
                        $statusMsg="Your plans settings successfully chenged.";
                        session_save(sid);
                        $params[sid]=$sid;
                        $params[action]='mainPanel';
                        $url="$baseURL/$webDIR/?".encode_params($params);
                        header("Location: $url");
                        exit_now();			
		break;
		case "sales":
			$sday =$HTTP_POST_VARS[sday];
			$smonth =$HTTP_POST_VARS[smonth];
			$syear =$HTTP_POST_VARS[syear];
                        $eday =$HTTP_POST_VARS[eday];
                        $emonth =$HTTP_POST_VARS[emonth];
                        $eyear =$HTTP_POST_VARS[eyear];
			
			$details[start] = date("Y-m-d",mktime(0,0,0,$smonth,$sday,$syear));
			$details[end]  = date("Y-m-d",mktime(0,0,0,$emonth,$eday,$eyear));

			$fileTemplate= 'sales.html';
			 include('main.html');    			

			
			
		break;

		case "search_reseller":

			$params[reseller] = validate($HTTP_POST_VARS[reseller]);
			$params[id] = validate($HTTP_POST_VARS[rid]);
			$params[email] = validate($HTTP_POST_VARS[email]);
			$params[firstname] = validate($HTTP_POST_VARS[firstname]);
			$params[lastname] = validate($HTTP_POST_VARS[lastname]);
			$params[country] = validate($HTTP_POST_VARS[country]);
			$params[state] = validate($HTTP_POST_VARS[state]);
			$params[ip] = validate($HTTP_POST_VARS[ip]);
			$params[client]=validate($HTTP_POST_VARS[client]);
			$params[domain]=validate($HTTP_POST_VARS[domain]);

			$fileTemplate="search.html";
			include("main.html");
		break;
		case  "client_search":
			$client=$HTTP_POST_VARS[client];
			if(!$client && !$reseller) exit("specify client and/or reseller ");
			$fileTemplate="client_search.html";
			include("main.html");
		break;
		case "client_refund":

			$comment=$HTTP_POST_VARS[refund_comment];
			$refund_type=$HTTP_POST_VARS[type];
			$sale_ids = $HTTP_POST_VARS[sale_id]; 			
			
			if(!is_array($sale_ids) || !$comment ||!$refund_type){ $errorMsg="please enter both comment and refund type";$fileTemplate="client_refund.html";include("main.html");exit();}
			if(!make_refund($client,$comment,$refund_type,$sale_ids)){ $errorMsg="fatal error(hiena :P)";$fileTemplate="client_refund.html";include("main.html");exit();}		
			if(block_hosting_user($client)) { $errorMsg="error  while blocking user, please do the blocking from the hosting admin system";$fileTemplate="client_refund.html";include("main.html");exit();};
			$statusMsg="ok";
			$fileTemplate="client_refund.html";
			include("main.html");			
		break;
		case "set_mail":
			$subject=$HTTP_POST_VARS[subject]; 
			$body=$HTTP_POST_VARS[body]; 
			$file=$HTTP_POST_VARS[file]; 
			$params[file]=$file;
			if(!validate($subject)){ $errorCode=1; $errorMsg=" invalid subject "; $fileTemplate='mail.html'; include('main.html'); exit(); } 
			if(!$body){ $errorCode=1; $errorMsg=" invalid body "; $fileTemplate='mail.html'; include('main.html'); exit(); } 
			if(!$file){ $errorCode=1; $errorMsg=" invalid file "; $fileTemplate='mail.html'; include('main.html'); exit(); } 
			if(!set_mail($file,$subject,$body)) { $errorCode=1; $errorMsg="fatal errro "; $fileTemplate='mail.html'; include('main.html'); exit(); };			
			
			$fileTemplate="mail.html";
                        include("main.html");
		break;
		case "services":
			$data = $HTTP_POST_VARS[data];
			if(!set_service_prices($data)){ $errorMsg="Error -1 "; $fileTemplate='services.html'; include('main.html'); exit(); }
			
			$errorMsg="Service prices set OK !";
                        $fileTemplate="services.html";
                        include("main.html");			
		break;
		case "last_sales":
			$s=$HTTP_POST_VARS[s];
			$fileTemplate="last_sales.html";
			include("main.html");
		break;
		case "delete_sale":
			if(!delete_sale($sale_id)){ $errorMsg="Error Deleting sale "; $fileTemplate='last_sales.html'; include('main.html'); exit(); }
			$fileTemplate="last_sales.html";
			include("main.html");
		break;
		case "last_reseller_sales":
			$s=$HTTP_POST_VARS[s];
			$fileTemplate="last_reseller_sales.html";
			include("main.html");
		break;
		case "block_reseller":
			$comment  =$HTTP_POST_VARS[comment];
			$id  =$HTTP_POST_VARS[id];
			$resellername=$HTTP_POST_VARS[resellername];
			$blocked=$HTTP_POST_VARS[blocked];
			if($comment)add_comment($id,$comment);
			$pass='sd123AsPf';
			if($blocked=='blocked' && !change_all_mailbox_pass($id,$pass)) { $errorMsg="Error Changing Mailboxes Password"; $fileTemplate='block_reseller.html'; include('main.html'); exit(); }
			if(!block_reseller($resellername,$blocked)){
				{ $errorMsg="Error Blocking"; $fileTemplate='block_reseller.html'; include('main.html'); exit(); }
			}
			exit("<script>window.close()</script>");
		break;
		case "w9_submit":
			$id  =$HTTP_POST_VARS[id];
			$resellername=$HTTP_POST_VARS[resellername];
			$w9_form=$HTTP_POST_VARS[w9_form];
			if(!w9_form_submit($resellername,$blocked)){
				{ $errorMsg="Error Submitting"; include('submit_w9_form.html'); exit(); }
			}
			exit("<script>window.close()</script>");
		break;
		case "view_affiliates":
			$subaction=$HTTP_POST_VARS[subaction];
			switch($subaction){
				case "remove_affiliates":
					$affiliates=$HTTP_POST_VARS[affiliates];
					if(!is_array($affiliates)){ $errorMsg="Sealect at least one affiliate";include('view_affiliates.html'); exit();}
					if(!remove_affiliates($affiliates)){
						$errorMsg="Error removing affiliates";include('view_affiliates.html'); exit();
					}
				break;
				case "remove_referer":
					$resellerid=$HTTP_POST_VARS[resellerid];
					if(!remove_referer($resellerid)){
						$errorMsg="Error removing referer";include('view_affiliates.html'); exit();
					}
				break;
				case "add_affiliate":
					$affiliate_id=$HTTP_POST_VARS[affiliate_id];
					if(!add_affiliate($resellername,$affiliate_id)){
						$errorMsg="Error adding referer";include('view_affiliates.html'); exit();
					}
				break;
				case "add_referer":
					$referer=$HTTP_POST_VARS[referer];
					if(!add_referer($resellername,$referer)){
						$errorMsg="Error adding referer";include('view_affiliates.html'); exit();
					}
				break;
			}
			include('view_affiliates.html'); exit();
		break;
		case "broken_billing_search":
			$arr=$HTTP_POST_VARS[arr];
			$fileTemplate="broken_billing.html";
                        include("main.html");
			exit_now();
		break;
		case "broken_billing":
			$sida=$HTTP_POST_VARS[sida];
			$order_number=$HTTP_POST_VARS[order_number];
			$b_act=$HTTP_POST_VARS[b_act];

			if(!$sida || !$order_number) { $errorMsg="fill alla the fields";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			include('../u/functions.php');
			switch($b_act){
	
			case 'signup_r':
				if(!add_plan_sale_r($sida)){ $errorMsg="Error adding plan_sale";$fileTemplate="broken_billing.html";include("main.html"); exit();}
				create_hosting_account_ph2($sida,0);
				//if(!create_hosting_account($sida)){ $errorMsg="Error creating acc call hiena imediately ($order_number)";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			break;
			case 'signup':
				if(!add_plan_sale($sida)){ $errorMsg="Error adding plan_sale";$fileTemplate="broken_billing.html";include("main.html"); exit();}
				if(!create_hosting_account_ph2($sida,0)){
					$errorMsg="Error creating acc  ($order_number)";$fileTemplate="broken_billing.html";include("main.html"); exit();
				}
				//if(!create_hosting_account($sida)){ $errorMsg="Error creating acc call hiena imediately ($order_number)";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			break;
			case 'register_domain':
				if(!register_domain($sida)){ $errorMsg="Error creating registering domain call hiena imediately ($order_number)";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			break;
			default :
				$errorMsg="No billing action ($order_number)";$fileTemplate="broken_billing.html";include("main.html"); exit();
			break;
			}

			exit("all good");
		break;
		case "broken_domain_register":
			$sida=$HTTP_POST_VARS[sida];
			if(!$sida) { $errorMsg="fill alla the fields";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			include('../u/functions.php');
			if(!register_domain($sida)){ $errorMsg="Error reg domain call hiena imediately ";$fileTemplate="broken_billing.html";include("main.html"); exit();}
			exit("all goodd");
		break;
		case "referer_details":
                        $referer =$HTTP_POST_VARS[referer];
                        $sday =$HTTP_POST_VARS[sday];
                        $smonth =$HTTP_POST_VARS[smonth];
                        $syear =$HTTP_POST_VARS[syear];
                        $eday =$HTTP_POST_VARS[eday];
                        $emonth =$HTTP_POST_VARS[emonth];
                        $eyear =$HTTP_POST_VARS[eyear];

                        $details[start] = date("Y-m-d",mktime(0,0,0,$smonth,$sday,$syear));
                        $details[end]  = date("Y-m-d",mktime(0,0,0,$emonth,$eday,$eyear));

                        $fileTemplate= 'referer_details.html';
                        include('main.html');
                        exit_now();
		break;
		default:
                        $fileTemplate="mainPanel.html";
                        include("main.html");        	       	
	        break;

        }
}
?>
